<template>
  <div class="windomask">
    <div class="modal">
      <div class="container">
        <div class="title">
          {{ title }}
          <div class="cancle">
            <i class="el-icon-close" @click="$emit('cancel')"></i>
          </div>
        </div>
        <div class="bodysty"><slot name="body"></slot></div>
        <!-- 这里可以通过传入的类型去显示不同样式 -->
        <div class="btn" v-if="btnType == 1">
          <!-- 触发失败的操作 -->
          <button class="cancelbtn" @click="$emit('cancel')">取消</button>
          <!-- 触发成功的操作 -->
          <button class="submitbtn" @click="$emit('submit')">保存</button>
        </div>
        <div class="btn" v-if="btnType == 2">
          <!-- 触发失败的操作 -->
         <button class="submitbtn" @click="$emit('submit')">删除订单</button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    title: {
      type: String,
      default: "",
    },
    btnType: {
      type: Number,
      default: 1,
    },
  },
};
</script>

<style lang="scss" scoped>
.windomask{
  position: fixed;
  background: rgba(0,0,0,0.2);
  width: 100vw;
  height: 100vh;
  z-index: 99;
  top: 0;
  left: 0;
}
.modal {
  position: fixed;
  z-index: 100;
  min-width: 500px;
  width: 40%;
  background-color: white;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  .bodysty {
    padding: 0 40px;
  }
  .title {
    text-align: center;
    padding: 15px;
    font-size: 16px;
    line-height: 24px;
  }
  .cancle {
    cursor: pointer;
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 25px;
  }
  .btn {
    text-align: right;
    padding: 15px;
    font-size: 16px;
    button {
      width: 70px;
      height: 34px;
      margin-right: 10px;
      border: 1px solid rgb(204, 204, 204);
      color: rgb(112, 116, 115);
      background-color: #fff;
      transition: all 0.2s ease 0s;
      border-radius: 2px;
      cursor: pointer;
      font-size: 14px;
    }
    .cancelbtn {
      // background-color: #f2123f !important;
      &:hover {
        background-color: rgb(151, 151, 151);
        border-color: rgb(151, 151, 151);
        color: rgb(255, 255, 255);
      }
    }
    .submitbtn {
      background-color: rgb(68, 168, 242);
      border-color: rgb(68, 168, 242);
      color: #fff;
      &:hover {
        background-color: rgb(61, 151, 218);
        border-color: rgb(61, 151, 218);
        text-decoration: none;
      }
    }
  }
}
</style>